home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Demo's / Igor Demo Pro / 1 PutContentsIn Igor Pro Folder / WaveMetrics Procedures / Data Manipulation / Concatenate Waves next >
Text File  |  1995-12-31  |  1KB  |  56 lines

  1. #pragma rtGlobals = 1
  2.  
  3. #include <Strings as Lists>
  4.  
  5. //    ConcatenateWaves(w1, w2)
  6. //        Tacks the contents of w2 on the to end of w1.
  7. //        If w1 does not exist, it is created.
  8. //        This is designed for 1D waves only.
  9. Function ConcatenateWaves(w1, w2)
  10.     String w1, w2
  11.     
  12.     Variable numPoints1, numPoints2
  13.  
  14.     if (Exists(w1) == 0)
  15.         Duplicate $w2, $w1
  16.     else
  17.         numPoints1 = numpnts($w1)
  18.         numPoints2 = numpnts($w2)
  19.         Redimension/N=(numPoints1 + numPoints2) $w1
  20.         Wave/C/D ww1=$w1
  21.         Wave/C/D ww2=$w2
  22.         ww1[numPoints1, ] = ww2[p-numPoints1]
  23.     endif
  24. End
  25.  
  26. //    ConcatenateWavesInList(dest, wl)
  27. //        Makes a dest wave that is the concatenation of the source waves.
  28. //        Overwrites the dest wave if it already exists.
  29. //        wl is assumed to contain at least one wave name.
  30. //        This is designed for 1D waves only.
  31. Function ConcatenateWavesInList(dest, wl)
  32.     String dest        // name of output wave
  33.     String wl        // semicolon separated list of waves ("w0;w1;w2;")
  34.     
  35.     Variable i                    // for walking through wavelist
  36.     String theWaveName
  37.     Variable destExisted
  38.     
  39.     destExisted = Exists(dest)
  40.     if (destExisted)
  41.         Redimension/N=0 $dest
  42.     endif
  43.     
  44.     i = 0
  45.     do
  46.         theWaveName = GetStrFromList(wl, i, ";")
  47.         if (strlen(theWaveName) == 0)
  48.             break                                        // no more waves
  49.         endif
  50.         if (cmpstr(theWaveName, dest) != 0)        // don't concat dest wave with itself
  51.             ConcatenateWaves(dest, theWaveName)
  52.         endif
  53.         i += 1
  54.     while (1)
  55. End
  56.